package pers.xuyong.strive.datastruct.tree;

import java.util.Scanner;

/**
 * 二叉树测试
 *
 * @author billymac
 * @version 1.0
 * @date 17/8/8  下午3:54
 * @since JDK1.8
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BinaryTree tree = new BinaryTree();
        //节点插入
        while (true) {
            System.out.println("请输入节点key值 : ");
            int key = sc.nextInt();
            System.out.println("请输入节点value值 : ");
            double value = sc.nextDouble();
            tree.insert(key, value);
            System.out.println(value);
            if(value == -1)
                break;
        }

        //二叉树遍历
        System.out.println("中序遍历:");
        tree.display(tree.root);
        System.out.println("前序遍历:");
        tree.leftDisplay(tree.root);
        System.out.println("后序遍历:");
        tree.rightDisplay(tree.root);

//        //节点查找
//        while (true) {
//            System.out.println("请输入查找节点value值 : ");
//            double value = sc.nextDouble();
//            Node node = tree.findNode(value);
//            if(node == null)
//                System.out.println("节点不存在!");
//            else
//                node.display();
//            if(value == -1)
//                break;
//        }

    }
}
